package com.share.shareplatform.sharegoods.service.impl;


import com.share.shareplatform.pojo.Shop;
import com.share.shareplatform.pojo.User;
import com.share.shareplatform.sharegoods.dao.ShopDao;
import com.share.shareplatform.sharegoods.service.ShopService;
import com.share.shareplatform.sharegoods.service.feign.UserService;
import com.share.shareplatform.util.Result;
import io.seata.spring.annotation.GlobalTransactional;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("shopService")
public class ShopServiceImpl implements ShopService {

    @Autowired
    private ShopDao shopDao;

    @Autowired
    private UserService userService;

    @Override
    public Long addOne(Shop shop) {
        return shopDao.addOne(shop);
    }

    @Override
    public Integer updateOne(Shop shop) {
        return shopDao.updateOne(shop);
    }

    @Override
    public Integer deleteOneById(Long id) {
        return shopDao.deleteOneById(id);
    }

    @Override
    public Integer deleteAllByIds(Long[] ids) {
        return shopDao.deleteAllByIds(ids);
    }

    @Override
    public Shop findOneByName(String name) {
        return shopDao.findOneByName(name);
    }

    @Override
    public Shop findOneById(Long id) {
        return shopDao.findOneById(id);
    }

    @Override
    public Shop findOneByUserId(Long id) {
        return shopDao.findOneByUserId(id);
    }

    @GlobalTransactional(name = "global_test",rollbackFor = Exception.class)
    public int test(Shop shop){
        User u=new User();
        u.setUsername("123");
        u.setPassword("123");
        Result test = userService.test(u);

        shopDao.addOne(shop);
        return 1;
    }


}
